package euler.p001_050;

import euler.MainEuler;

public class Euler040 extends MainEuler {

    /*
        An irrational decimal fraction is created
        by concatenating the positive integers:

        0.123456789101112131415161718192021...

        It can be seen that the 12th digit of the fractional part is 1.

        If dn represents the nth digit of the fractional
        part, find the value of the following expression.

        d1 × d10 × d100 × d1000 × d10000 × d100000 × d1000000

     */
    public String resolve() {

        StringBuilder sb = new StringBuilder(1000000);
        int i = 1;
        while (sb.length() < 1000000) {
            sb.append(i++);
        }
        return String.valueOf((sb.charAt(1 - 1) - '0')*
                (sb.charAt(10 - 1) - '0') *
                (sb.charAt(100 - 1) - '0') *
                (sb.charAt(1000 - 1) - '0') *
                (sb.charAt(10000 - 1) - '0') *
                (sb.charAt(100000 - 1) - '0') *
                (sb.charAt(1000000 - 1) - '0'));
    }

}
